﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Intorise.Framework;

namespace TestWindowsFormsApplication
{
    public partial class FormTestCode : Form
    {
        public FormTestCode()
        {
            InitializeComponent();
            this.txtSoftwareName.Text = Application.ProductName;
            this.txtCode.Text = Security.GetCode(this.txtSoftwareName.Text);
            this.txtSN.Text = Security.GetSN(this.txtCode.Text);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (this.txtSoftwareName.Text != "")
            {
                this.txtCode.Text = Security.GetCode(this.txtSoftwareName.Text);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (this.txtCode.Text != "" && this.txtSN.Text != "")
            {

                Security.ValidateResult result = Security.Validate(this.txtSoftwareName.Text, this.txtCode.Text, this.txtSN.Text);
                if (result.Success)
                {
                    MessageBox.Show("机器码联网验证通过，您的使用时间还剩余" + result.TimeLimit.Days + "天" + result.TimeLimit.Hours + "小时" + result.TimeLimit.Minutes + "分");
                }
                else
                {
                    MessageBox.Show("机器码联网验证失败");
                }
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            if (this.txtCode.Text != "")
            {
                this.txtSN.Text = Security.GetSN(this.txtCode.Text);
            }
        }
    }
}
